home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
Tickle-4.0 (tcl)
/
src
/
tclEngine.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-08
|
4KB
|
181 lines
/*
** Copyright © 1991 ICE Engineering, Inc.
** All rights reserved.
** 8840 Main St.
** Whitmore Lake, Mi. 48189
**
** Written by Tim Endres.
*/
/*
** The following macro definition will cause the global varaible
** definitions to allocate storage, versus just "extern" definitions.
** One and only one compiled file should declare this macro.
** (refer to pages 28-30, "Scope; External Variables",
** in Kernigan and Richie, "The C Programming Language").
*/
#define ALLOCATE_GLOBALS 1
#undef USEDUMP
#undef MAKEDUMP
#include "tickle.h"
#include "TGE.h"
#include "asd.h"
#include "mb.h"
#include <GestaltEqu.h>
char **environ = NULL;
main(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
int myerr, i;
long gestaltLong;
char **myenv;
#ifdef THINK_C
myenv = NULL;
#else
myenv = envp;
#endif
if (myenv == NULL)
{
environ = (char **) malloc( 5 * sizeof(char *) );
if (environ == NULL)
{
exit(0);
}
i = 0;
#ifdef TCL_LIBRARY
{
char buffer[1024];
sprintf(buffer, "TCL_LIBRARY=%s", TCL_LIBRARY);
environ[i] = ckalloc( strlen(buffer) + 1 );
strcpy(environ[i++], buffer);
}
#else
environ[i++] = "TCL_LIBRARY=:library";
#endif
#ifdef THINK_C
environ[i++] = "THINK_VERSION=1";
#endif
#ifdef MPW
environ[i++] = "MPW_VERSION=1";
#endif
environ[i] = NULL;
}
else
{
environ = myenv;
}
/*
** Initialize the Macintosh ROM managers that the Unifolder application
** uses. This is required by all Macintosh applications.
*/
/* Increase stack space by 12,000 bytes */
SetApplLimit(GetApplLimit() - (12 * 1024));
/* Expand the application heap zone to the maximum. */
MaxApplZone();
/* Allocate a bunch of master pointers. */
MoreMasters();
MoreMasters();
MoreMasters();
MoreMasters();
/*
** Initialize the Macintosh ROM managers that the Unifolder application
** uses. This is required by all Macintosh applications.
*/
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs((ResumeProcPtr)0);
InitCursor();
InitAllPacks();
if (GestaltAvailable()) {
myerr = Gestalt(gestaltHelpMgrAttr, &gestaltLong);
if (myerr == noErr)
if ((gestaltLong & (1 << gestaltHelpMgrPresent)) != 0)
gHasBalloons = true;
myerr = Gestalt(gestaltFindFolderAttr, &gestaltLong);
if (myerr == noErr)
if ((gestaltLong & (1 << gestaltFindFolderPresent)) != 0)
gHasDirectory = true;
myerr = Gestalt(gestaltAppleEventsAttr, &gestaltLong);
if (myerr == noErr)
if ((gestaltLong & (1 << gestaltAppleEventsPresent)) != 0)
gHasAppleEvents = true;
}
memset(&theEnviron, 0, sizeof(SysEnvRec));
#define CurrentVersion 1
if (SysEnvirons(CurrentVersion, &theEnviron) != noErr) {
theEnviron.environsVersion = -1;
theEnviron.hasColorQD = 0;
theEnviron.hasFPU = 0;
switch (theEnviron.keyBoardType) {
case envMacKbd: /* "Macintosh" */
case envMacAndPad: /* "Macintosh with Pad" */
case envMacPlusKbd: /* "MacPlus" */
macplus_keybd = 1;
break;
}
message_alert("%s%s",
"This is a *very* old Mac isn't it?\015Things may not operate properly.");
}
/*
** Initialize things used by the application.
*/
InitApplication();
tar_initialize();
InitFeedbackWindow();
/*
** app_done = true --> Quit the application.
*/
app_done = false;
/*
** Loop forever on the application's event loop until
** the app_done flag is set by a "quit" command.
*/
while (! app_done) {
while (! app_done) do_event();
ShutDownApplication();
}
/*
** All done, exit...
*/
exit();
}